﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BaseEntities;
using BussinessLogic;

namespace ATMSystem_G5_HaUI.UC1.Control
{
    public partial class ValidPIN : System.Web.UI.UserControl
    {
        string str = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Session["PIN"] = null;
            }
        }

        protected void num1_Click(object sender, EventArgs e)
        {
            str = "1";
            txtCardPIN.Text = str;
        }

        protected void num2_Click(object sender, EventArgs e)
        {
            str = str + "2";
            txtCardPIN.Text = str;
        }

        protected void num3_Click(object sender, EventArgs e)
        {
            str = str + "3";
            txtCardPIN.Text = str;
        }

        protected void num4_Click(object sender, EventArgs e)
        {
            str = str + "4";
            txtCardPIN.Text = str;
        }

        protected void num5_Click(object sender, EventArgs e)
        {
            str = str + "5";
            txtCardPIN.Text = str;
        }

        protected void num6_Click(object sender, EventArgs e)
        {
            str = str + "6";
            txtCardPIN.Text = str;
        }

        protected void num7_Click(object sender, EventArgs e)
        {
            str = str + "7";
            txtCardPIN.Text = str;
        }

        protected void num8_Click(object sender, EventArgs e)
        {
            str = str + "8";
            txtCardPIN.Text = str;
        }

        protected void num9_Click(object sender, EventArgs e)
        {
            str = str + "9";
            txtCardPIN.Text = str;
        }

        protected void btnEnter_Click(object sender, EventArgs e)
        {
            
                Card card = new Card();
                card.PIN = txtCardPIN.Text;
                if (ValidationLogic.ValidPIN(card) == true)
                {
                    Session["PIN"] = "true";
                    Response.Redirect("MainMenu.aspx");
                }
                else
                {
                    ValidationLogic.UpdateAttempt(card);
                }
            
        }

        protected void btnClear_Click(object sender, EventArgs e)
        {

        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {

        }

        protected void num0_Click(object sender, EventArgs e)
        {
            str = str + "0";
            txtCardPIN.Text = str;
        }
    }
}